package bist.believeinstep.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import bist.believeinstep.domain.Tour;
import bist.believeinstep.util.Constant.State;
import bist.believeinstep.util.Constant.TourType;

public class TourMapper implements RowMapper<Tour> {
	public Tour mapRow(ResultSet rs, int rowNum) throws SQLException{
		
		Tour tour = new Tour();
		
		tour.setId(rs.getInt("id"));
		tour.setCode(rs.getString("code"));
		tour.setName(rs.getString("name"));
		tour.setAvatar(rs.getString("avatar"));
		tour.setDuration(rs.getInt("duration"));
		tour.setDateStart(rs.getTimestamp("date_start"));
		tour.setDateEnd(rs.getTimestamp("date_end"));
		tour.setContent(rs.getString("content"));
		tour.setTicketNumber(rs.getInt("ticket_number"));
		tour.setFrom(rs.getString("from"));
		tour.setTo(rs.getString("to"));
		tour.setIsHot(rs.getBoolean("is_hot"));
		
		String type = rs.getString("type");
		tour.setType(TourType.create(type));
		
		String state = rs.getString("state");
		tour.setState(State.create(state));
		
		tour.setCreated(rs.getTimestamp("created_date"));
		tour.setModified(rs.getTimestamp("modified_date"));
		tour.setCreatedBy(rs.getString("created_by"));
		tour.setModifiedBy(rs.getString("modified_by"));
		tour.setTourPriceId(rs.getInt("bist_tour_prices_id"));
		
		return tour;
	}
}
